import os
import shutil

def delete_c_files():
    # 获取当前工作目录
    current_directory = os.getcwd()
    # 遍历当前目录及其子目录
    for root, dirs, files in os.walk(current_directory):
        for dir in dirs:
            if dir == "__pycache__":
                pycache_path = os.path.join(root, dir)
                try:
                    shutil.rmtree(pycache_path)
                    print(f"Deleted: {pycache_path}")
                except Exception as e:
                    print(f"Error deleting {pycache_path}: {e}")

if __name__ == "__main__":
    delete_c_files()